package com.szxy.common.redis.controller;

import com.szxy.common.redis.service.UserService;
import com.szxy.pojo.TbUser;
import com.szxy.utils.UserToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:zwer
 * @Date:2019/9/12 15:57
 * @Description:com.szxy.common.redis.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/service/redis/user")
public class RedisUserController {

    @Autowired
    private UserService userService;

    /**
     * 添加 User 的 Token 数据
     * @param tbUser
     * @param token
     */
    @RequestMapping(value="/insertUserToken",method= RequestMethod.POST)
    public void insertUserToken(@RequestBody TbUser tbUser, @RequestParam("token") String token){
        this.userService.insertUserToken(tbUser,token);
    }

    /**
     *  获取 User  数据
     * @param token
     * @return
     */
    @RequestMapping(value="/getUserToken",method=RequestMethod.POST)
    public TbUser getUserToken(@RequestParam("token") String token){
        return this.userService.getUserToken(token);
    }

    /**
     * 移除 User 数据
     * @param token
     */
    @RequestMapping(value="/removeUserToken",method=RequestMethod.POST)
    void removeUserToken(@RequestParam("token") String token){
        this.userService.removeUserToken(token);
    }

    @RequestMapping(value="/checkUserToken")
    TbUser checkUserToken(@RequestParam  String userToken){
        return this.userService.checkUserToken(userToken);
    }

}
